<!doctype html>
<html lang="zh">

<head>
    <meta charset="utf-8">
    <title>注册</title>
    {% load static %}
    <!-- Bootstrap 5 CDN -->
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/css/site.css" rel="stylesheet">
    <style>
        body {
            background: 
                radial-gradient(900px 440px at -10% -10%, rgba(79,70,229,0.12), transparent 60%),
                radial-gradient(840px 420px at 110% -10%, rgba(16,185,129,0.12), transparent 60%),
                #f7f8fb;
            min-height: 100vh;
            display: flex;
            align-items: center;
            padding: 20px 0;
        }
        .register-container {
            max-width: 450px;
            margin: auto;
        }
        .logo-img {
            text-align: center;
            margin-bottom: 20px;
        }
        .logo-img img {
            width: 80px;
            height: 80px;
            object-fit: cover;
        }
        .card {
            border-radius: 14px;
            border: 1px solid rgba(17, 24, 39, .06);
            box-shadow: 0 10px 24px rgba(0, 0, 0, .06);
            transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
        }
        .card:hover {
            transform: translateY(-2px); 
            box-shadow: 0 16px 36px rgba(0,0,0,.10); 
            border-color: rgba(17,24,39,.10); 
        }
        .card-header {
            background: linear-gradient(135deg, #4f46e5, #7c3aed);
            color: white;
            border-radius: 14px 14px 0 0 !important;
            text-align: center;
            padding: 20px;
        }
        .form-control {
            border: 1px solid rgba(17, 24, 39, .12);
            border-radius: 10px;
            padding: 10px 12px;
            background: #fff;
            outline: none;
            transition: box-shadow .15s ease, border-color .15s ease;
        }
        .form-control:focus {
            border-color: #4f46e5;
            box-shadow: 0 0 0 4px rgba(79, 70, 229, .2);
        }
        .btn-primary {
            background: #4f46e5;
            border-color: #4f46e5;
            border-radius: 10px;
            font-weight: 600;
            transition: transform .08s ease, box-shadow .2s ease, filter .2s ease;
            padding: 10px;
        }
        .btn-primary:hover {
            background: #4338ca;
            border-color: #4338ca;
            box-shadow: 0 8px 18px rgba(79,70,229,.25);
        }
        .btn-primary:active { 
            transform: translateY(1px) scale(0.99); 
            filter: brightness(.98); 
        }
        .btn-outline-primary {
            border-color: #4f46e5;
            color: #4f46e5;
        }
        .btn-outline-primary:hover {
            background: #4f46e5;
            color: white;
            box-shadow: 0 8px 18px rgba(79,70,229,.25);
        }
        .alert {
            border-radius: 10px;
        }
        .captcha-container {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .captcha-img {
            height: 38px;
        }
        .captcha-refresh {
            cursor: pointer;
            color: #4f46e5;
            font-size: 0.8rem;
        }
    </style>
</head>

<body>
    <div class="container register-container">
        <div class="logo-img">
            <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" fill="currentColor" class="bi bi-person-plus-fill" viewBox="0 0 16 16">
                <path d="M1 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H1zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/>
                <path fill-rule="evenodd" d="M13.5 5a.5.5 0 0 1 .5.5V7h1.5a.5.5 0 0 1 0 1H14v1.5a.5.5 0 0 1-1 0V8h-1.5a.5.5 0 0 1 0-1H13V5.5a.5.5 0 0 1 .5-.5z"/>
            </svg>
        </div>
        
        <div class="card shadow">
            <div class="card-header">
                <h3 class="mb-0">大学生论坛系统</h3>
                <p class="mb-0 mt-1">用户注册</p>
            </div>
            <div class="card-body p-4">
                <form action="" method="post" novalidate>
                    {% csrf_token %}
                    <div class="mb-3">
                        <label class="form-label">{{ form.username.label }}</label>
                        {{ form.username }}
                        {% if form.username.errors %}
                        {% for error in form.username.errors %}
                        <div class="alert alert-danger mt-2" role="alert">
                            {{ error }}
                        </div>
                        {% endfor %}
                        {% endif %}
                    </div>
                    <div class="mb-3">
                        <label class="form-label">{{ form.password.label }}</label>
                        {{ form.password }}
                        {% if form.password.errors %}
                        {% for error in form.password.errors %}
                        <div class="alert alert-danger mt-2" role="alert">
                            {{ error }}
                        </div>
                        {% endfor %}
                        {% endif %}
                    </div>
                    <div class="mb-3">
                        <label class="form-label">{{ form.password2.label }}</label>
                        {{ form.password2 }}
                        {% if form.password2.errors %}
                        {% for error in form.password2.errors %}
                        <div class="alert alert-danger mt-2" role="alert">
                            {{ error }}
                        </div>
                        {% endfor %}
                        {% endif %}
                    </div>
                    <div class="mb-3">
                        <label class="form-label">{{ form.captcha.label }}</label>
                        <div class="captcha-container">
                            {{ form.captcha }}
                            <span class="captcha-refresh" id="refresh-captcha">刷新</span>
                        </div>
                        {% if form.captcha.errors %}
                        {% for error in form.captcha.errors %}
                        <div class="alert alert-danger mt-2" role="alert">
                            {{ error }}
                        </div>
                        {% endfor %}
                        {% endif %}
                    </div>
                    <button type="submit" class="btn btn-primary w-100 mb-3">注册</button>
                    <a class="btn btn-outline-primary w-100" href="{% url 'user:login' %}">已有账号？去登录</a>
                </form>
            </div>
        </div>
    </div>

    <!-- Bootstrap 5 JS（可选，若需要交互组件） -->
    <script src="/static/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="/static/js/jquery-3.6.1.min.js"></script>
    <script>
        $(document).ready(function() {
            $('#refresh-captcha').click(function () {
                $.getJSON("/captcha/refresh/", function (result) {
                    $('.captcha').attr('src', result['image_url']);
                    $('#id_captcha_0').val(result['key'])
                });
            });
        });
    </script>
</body>

</html>